package org.jivesoftware.openfire.plugin.common;

public enum ResponseMessage {

    SUCCESS(200, "操作成功！", true),
    FAILURE(201, "操作失败！", false),
    SUCCESS_NOT_FOUND(201, "数据为空", true),
    ;


    private int code;

    private String message;

    private boolean success;

    private ResponseMessage(int code, String message, boolean success) {
        this.code = code;
        this.message = message;
        this.success = success;
    }


    public int getCode() {
        return code;
    }

    public String getMessage() {
        return this.message;
    }

    public boolean getSuccess() {
        return this.success;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public void setSuccess(boolean success) {
        this.success = success;
    }

    public Result<?> messageToResult() {
        Result<?> result = new Result<>();
        result.setCode(this.getCode());
        result.setSuccess(this.getSuccess());
        result.setMessage(this.getMessage());
        return result;
    }

    public Result<?> messageToResult(Object obj) {
        Result<?> result = new Result<>();
        result.setCode(this.getCode());
        result.setSuccess(this.getSuccess());
        result.setMessage(this.getMessage());
        result.setData(obj);
        return result;
    }

}
